package cn.yili12.business.mq.handler;

import cn.yili12.business.entity.MessageDb;
import cn.yili12.business.mq.bean.Message;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class SendHandler extends BaseHandler {

    @Override
    public boolean handler(Message message) {
        MessageDb messageDb = new MessageDb();
        messageDb.setData(message.getData());
        messageDb.setFromUser(message.getFrom());
        messageDb.setToUser(message.getTo());
        messageDb.setNo(message.getNo());
        messageDb.setSendTime(new Date());
        messageDb.setStatus(0);
        messageDb.setId(Long.valueOf(message.getNo()));
        service.save(messageDb);
        return true;
    }
}
